import { defineConfig } from 'vite'
import AutoImport from "unplugin-auto-import/vite"

import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import path from 'path';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
const pathSrc = path.resolve(__dirname, "src");

export default defineConfig({
  base: './',
  resolve: {
    alias: {
      "@": path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 7131,
    open: false,
    host: '0.0.0.0'
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return 'vendor'
          }
        }
      },
    },
  },
  plugins: [vue(), AutoImport({
    //安装两行后你会发现在组件中不用再导入ref，reactive等
    imports: [
      'vue',
      'vue-router', {
        'naive-ui': [
          'useDialog',
          'useMessage',
          'useNotification',
          'useLoadingBar'
        ]
      }],
    dts: "src/auto-import.d.ts",
    //ant-design-vue
    // AntDesignVueResolver(),
    resolvers: [NaiveUiResolver(), AntDesignVueResolver()],
  }),
  createSvgIconsPlugin({
    iconDirs: [path.resolve(pathSrc, 'assets/icons')], // 你的 SVG 目录
    symbolId: 'icon-[dir]-[name]',
  }),
  Components({
    directoryAsNamespace: true,
    resolvers: [
      AntDesignVueResolver({
        importStyle: false, // css in js
        resolveIcons: true
      }),
    ],
  }),],
})
